<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    var total=0;
    var num = parseInt(prompt("请输入考试的科目数"));
    if(num>0) {
        for (var i = 1; i <= num; i++) {
            var score = parseFloat(prompt("请输入成绩"));
            if (score < 0) {
                alert("分数录入有误");
                break;
            }
            total = total + score;
        }
    }else{
        alert("youwu");
    }

    alert(total);
</script>

</body>
</html>